<template>
	<view class="body">
		<view class="bor">
			<uv-qrcode ref="qrcode" size="180px" :hide='true' :value="invitePath"></uv-qrcode>
			<image :src="path" class="code" :show-menu-by-longpress='true'></image>
			<view class="code_msg">长按二维码发送给朋友，或保存到手机</view>
		</view>
	</view>
</template>


<script>
	import config_set from "../../baseUrl.js"
	import {
		getMemberInfo
	} from '@/api.js'
	export default {

		data() {
			let a = setInterval(() => {
				if (this.path) {
					clearInterval(a)
					return
				}
				this.$refs.qrcode.toTempFilePath({
					success: (ress) => {
						this.path = ress.tempFilePath
					}
				});
			}, 10)

			return {
				invitePath: '',
				path: ''
			}
		},
		onLoad() {
			this.GetUser()

		},
		methods: {
			async GetUser() {
				const url = config_set.inviteUrl
				let that = this
				let res = await getMemberInfo({})
				console.log(res.result.inviteCode);
				this.invitePath = url + '?inviteCode=' + res.result.inviteCode
				this.userInfo = res.result
				uni.setStorage({
					key: 'userInfo',
					data: JSON.stringify(res.result),
					success: function() {}
				});
			},

		}
	}
</script>

<style lang="scss" scoped>
	.body {
		background: #f8f8f8;
		height: 100vh;
		width: 100vw;
		padding: 30rpx 0;
		box-sizing: border-box;

	}

	.bor {
		height: calc(100vh - 100rpx);
		width: calc(100vw - 100rpx);
		margin: 50rpx;
		/* border: 4rpx solid #ff8248; */
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		padding-bottom: 300rpx;
		box-sizing: border-box;
		position: relative;


		.code {
			width: 40vw;
			height: 40vw;
		}

		.code_msg {
			margin-top: 80rpx;
			font-size: 32rpx;
		}
	}
</style>